package sort;

/**]
 * 
 * @author 26233
 * ð������
 * ÿ�ν�һ�����ֵð�ݵ����ұ�
 */
public class BubbleSort {

	public static void bubbleSort(int[] arr) {
		for(int i = arr.length - 1; i > 0; i--) {
			int start = 0;
			while(start < i) {
				if(arr[start] > arr[start + 1]) {
					int temp = arr[start + 1];
					arr[start + 1] = arr[start];
					arr[start] = temp;
				}
				start++;
			}
		}
	}
	
	public static void main(String[] args) {
		
		int[] arr = new int[] {3, 2, 6, 1, 7, 5, 8, 4};
		// int[] arr = new int[] {3};
		bubbleSort(arr);
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i] + " ");
		}
	}
	
}
